<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Videos extends Model
{
    const STATUS_1 = 1;//正常
    const STATUS_2 = 2;//禁用
    const OPTION_0 = 0;//未推荐
    const OPTION_1 = 1;//推荐
    const GOOD_0 = 0;//是精选
    const GOOD_1 = 1;//不是精选
    const WHEEL_0 = 0;//是轮播
    const WHEEL_1 = 1;//不是轮播


    const STATUS_TEXT = [
        self::STATUS_1 => '<span class="el-tag">正常</span>',
        self::STATUS_2 => '<span class="el-tag el-tag--danger">锁定</span>',
    ];
    const OPTION_TEXT = [
        self::OPTION_0 => '<span class="el-tag">否</span>',
        self::OPTION_1 => '<span class="el-tag">是</span>',
    ];
    const GOOD_TEXT = [
        self::GOOD_0 => '<span class="el-tag">否</span>',
        self::GOOD_1 => '<span class="el-tag">是</span>',
    ];
    const WHEEL_TEXT = [
        self::WHEEL_0 => '<span class="el-tag">否</span>',
        self::WHEEL_1 => '<span class="el-tag">是</span>',
    ];
    protected $table = 'videos';
    protected $fillable = [
        'title','thumb','time','view',
        'share','comment_count','cate_id','status','link','chanel_id',
        'option','sort','rand_cate','created_at','updated_at','userid','good','wheel','collect_count','zan_count','share_count'
    ];
    public function user(){
        return $this->belongsTo('App\Models\Users', 'userid', 'id');
    }

    public function cate(){
        return $this->belongsTo('App\Models\Cates', 'cate_id', 'id');
    }

    public function comment(){
        return $this->hasMany('App\Models\Comments', 'video_id', 'id');
    }

    public function zan(){
        return $this->hasMany('App\Models\VideosZan', 'video_id', 'id');
    }

    public function collect(){
        return $this->hasMany('App\Models\VideosCollect', 'video_id', 'id');
    }

    public function counts(){
        return $this->hasMany('App\Models\VideosCount', 'video_id', 'id');
    }

}
